class_name SlotBtn
extends TextureButton

#region 属性
@export var normal_color:Color
@export var hover_color:Color
@export var pressed_color:Color
@export var hover_scale:float = 1.06
@export var icon: TextureRect
var manager:CircleBtnView
var idx:int = -1
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func init_slot_btn(manager:CircleBtnView, idx:int):
	self.manager = manager
	self.idx = idx
	set_icon(null)
	rotation_degrees = idx * 45
	icon.rotation_degrees = -idx * 45
func set_icon(texture:Texture2D):
	icon.texture = texture
#endregion
#region 私有方法
func _on_texture_button_pressed() -> void:
	manager.switch(idx)
	var tween:Tween = create_tween()
	tween.tween_property(self,"self_modulate",pressed_color,0.1)
	tween.tween_property(self,"self_modulate",hover_color if is_hovered() else normal_color,0.1)
func _on_mouse_entered() -> void:
	manager.update_desc(idx)
	var tween:Tween = create_tween()
	tween.tween_property(self,"self_modulate",hover_color,0.1)
	tween.parallel()
	tween.tween_property(self,"scale",Vector2(hover_scale,hover_scale),0.1)
func _on_mouse_exited() -> void:
	manager.update_desc(-1)
	var tween:Tween = create_tween()
	tween.tween_property(self,"self_modulate",normal_color,0.1)
	tween.parallel()
	tween.tween_property(self,"scale",Vector2.ONE, 0.1)
#endregion
#region 生命周期函数
func _enter_tree() -> void:
	self_modulate = normal_color
#endregion
